package top.ivansong92.example.leetcode.learning.common.algorithms.greedy;


import org.junit.Test;

import java.util.Arrays;

public class TestExample4 {


    @Test
    public void testrob2V2() {

    }

    /**
     * 455. 分发饼干
     *
     * @return
     */
    public int findContentChildren(int[] g, int[] s) {
        if (g == null || g.length == 0 || s == null || s.length == 0) {
            return 0;
        }
        Arrays.sort(g);
        Arrays.sort(s);
        int gi = g.length - 1, si = s.length - 1;
        int res = 0;
        while (gi >= 0 && si >= 0) {
            if (s[si] >= g[gi]) {
                res ++;
                si --;
            }
            gi --;
        }
        return res;
    }

    public static String booleanToString(boolean input) {
        return input ? "True" : "False";
    }
}